import * as actionType from './constants.js';
import {reqSearch,reqSearchHotDetail} from '../../../api/index'

export const changeSearch = (data)=>{
    
    return{
        type: actionType.GET_SEARCH,
        data:data
    }
}

export const changeSearchHot = (data)=>{
    // console.log('进去成功.....')
    return{
        type: actionType.GET_SEARCHHOT,
        data:data
    }
}



export const getSearch = (keywords) =>{
    // console.log(keywords,'id');
    return (dispatch) =>{
        reqSearch(keywords)
            .then((res) =>{
               
                dispatch(changeSearch(res.data))
            })
            .catch((e) =>{
                console.log(e,'error')
            })
    }
}

export const getSearchHot = () =>{
    
    return (dispatch) =>{
        reqSearchHotDetail()
            .then((res) =>{
                // console.log(res,'key');
                dispatch(changeSearchHot(res.data))
            })
            .catch((e) =>{
                console.log(e,'error')
            })
    }
}


